<?php

namespace App\Http\Controllers;

use App\Traits\JsonResponse;
use App\Traits\UploaderTrait;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    use JsonResponse;
    use UploaderTrait;

    public function getPaginate($model, $page, $limit = 10)
    {
        $list = $model->paginate($limit, ['*'], 'page', $page);

        $total = $list->total();
        $items = $list->items();

        return compact('items', 'total', 'page', 'limit');
    }
}
